#pragma once
#include <Arbitrator.h>
#include <BWAPI.h>

class HarassmentManager : public Arbitrator::Controller<BWAPI::Unit*,double>
{
public:
	class HarasserData
	{
	public:
		enum HarasserMode
		{
			Idle,
			Harassing,
			Building,
			Fleeing
		};
		HarasserData(){ mode = Idle; }
		BWAPI::Position target;
		HarasserMode mode;
	};
	HarassmentManager(Arbitrator::Arbitrator<BWAPI::Unit*,double>* arbitrator);
	virtual void onOffer(std::set<BWAPI::Unit*> units);
	virtual void onRevoke(BWAPI::Unit* unit, double bid);
	virtual void update();

	virtual std::string getName() const;
	virtual std::string getShortName() const;
	void onRemoveUnit(BWAPI::Unit* unit);

	// Non-Controller methods.
	bool isHarassing() const;
	void setHarasserCount(int count);
	void enableDebugMode();

	std::map<BWAPI::Unit*, HarasserData> harassers;
	Arbitrator::Arbitrator<BWAPI::Unit*,double>* arbitrator;

	BWTA::BaseLocation *myStartLocation;

private:
	bool needMoreHarassers() const;
	void requestHarasser(double bid);
	void addHarasser(BWAPI::Unit* unit);
	void updateHarasserAssignments();


	size_t desiredHarasserCount;
	int harasseringStartFrame;
	bool debugMode;
};